package com.jiao.store.service.impl;

import com.jiao.store.entity.Districts;
import com.jiao.store.mapper.DistrictsMapper;
import com.jiao.store.service.DistrictsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DistrictsServiceImpl implements DistrictsService {


     @Autowired
    private DistrictsMapper districtsMapper;
    @Override
    public List<Districts> getParent(String parent) {
        List<Districts> list = districtsMapper.FindByParent(parent);
        //进行网络传输时，为了加速传递，避免无效数据传递，将无效数据设置为null
        for (Districts d :
                list) {
            d.setId(null);
            d.setParent(null);
        }
        return list;
    }

    @Override
    public String getNameByCode(String code) {
        return districtsMapper.FindNameByCode(code);
    }
}
